<?php

/*
 * 颜色装饰器
 * 
 */

namespace IMooc;

class ColorDrawDecorator implements DrawDecorator {

    //将想要更改的颜色保存在受保护的属性里
    protected $_color;

    //使用构造函数来接收想要更改的颜色
    function __construct($color = 'red')
    {
        $this->_color = $color;
    }

    function beforeDraw()
    {
        echo "<div style='color:{$this->_color};'>";
    }

    function afterDraw()
    {
        echo '</div>';
    }

}
